﻿#region license
// Copyright (c) 2008 - 2008 Ritesh Rao
// All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
// 
//     * Redistributions of source code must retain the above copyright notice,
//     this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright notice,
//     this list of conditions and the following disclaimer in the documentation
//     and/or other materials provided with the distribution.
//     * Neither the name of Ayende Rahien nor the names of its
//     contributors may be used to endorse or promote products derived from this
//     software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion

namespace Rhinestone.Domain
{
    /// <summary>
    /// Attachment entry associated with a <see cref="WorkItem"/> instance.
    /// </summary>
    public class Attachment
    {
        #region fields
        private int _attachmentID;
        private string _fileName;
        private AttachmentFile _file;
        private WorkItem _workItem;
        #endregion

        #region .ctor
        /// <summary>
        /// Inherited Constructor.
        /// Creates a new instance of the <see cref="Attachment"/> class.
        /// </summary>
        protected Attachment() {}

        /// <summary>
        /// Default Constructor.
        /// Creates a new instance of the <see cref="Attachment"/> class with
        /// the specified class name and <see cref="AttachmentFile"/>
        /// </summary>
        /// <param name="fileName">string. The name of the attachment.</param>
        /// <param name="file">An <see cref="AttachmentFile"/> instance containing the contents
        /// of the attachment.</param>
        public Attachment(string fileName, AttachmentFile file)
        {
            _fileName = fileName;
            _file = file;
        }
        #endregion

        #region properties
        /// <summary>
        /// Gets the unique ID assigned to the attachment.
        /// </summary>
        /// <value>int. The unique ID assigned to the attachment.</value>
        public virtual int AttachmentID
        {
            get { return _attachmentID; }
        }

        /// <summary>
        /// Gets the name of the attachment file.
        /// </summary>
        /// <value>string. The name of the attachment file.</value>
        public virtual string FileName
        {
            get { return _fileName; }
        }

        /// <summary>
        /// Gets or sets summary information about the attachment.
        /// </summary>
        /// <value>string. Summary information about the attachment.</value>
        public virtual string Summary { get; set; }

        /// <summary>
        /// Gets the <see cref="WorkItem"/> instance containing this <see cref="Attachment"/>
        /// instnace. 
        /// </summary>
        /// <value>The <see cref="WorkItem"/> that contains this attachment.</value>
        public virtual WorkItem WorkItem
        {
            get { return _workItem; }
            internal set { _workItem = value; }
        }

        /// <summary>
        /// Gets the <see cref="AttachmentFile"/> instance containing the contents of the attachment.
        /// </summary>
        /// <value>The <see cref="AttachmentFile"/> instance containing the contents of the attachment.</value>
        public virtual AttachmentFile File
        {
            get { return _file; }
        } 
        #endregion
    }
}
